'''
# 新增数据
heros = {'及时雨':'宋江','玉麒麟':'卢俊义','花和尚':'鲁智深','母夜叉':'孙二娘'}
heros['豹子头'] = '林冲'
print(heros)

# 修改
heros['及时雨'] = '宋公明'
print(heros)
dict_val = {'黑旋风':'李逵','入云龙':'公孙胜','花和尚':'鲁达'}
heros.update(dict_val) # 追加，如果重复，会在原位置覆盖原value
print(heros)
'''
# 删除 del , pop ,popitem , clear
# heros = {'及时雨':'宋江','玉麒麟':'卢俊义','花和尚':'鲁智深','母夜叉':'孙二娘'}
# del 删除一个元素或整个字典
# del heros['及时雨']
# print(heros)
# del heros
# print(heros)

# pop 根据键名删除
# heros.pop('和尚')
# print(heros)

# popitem 删除最后一个
# heros.popitem()
# heros.popitem()
# print(heros)

#  clear
# heros.clear()
# print(heros)

# 查询 in
# if '宋江' in heros:
#     print('该元素在字典中')
# else:
#     print('该元素不在字典中')

# 取值
heros = {'及时雨':'宋江','玉麒麟':'卢俊义','花和尚':'鲁智深','母夜叉':'孙二娘'}
# keys()
# keys = heros.keys()
# print(keys)
# print(list(keys))
# for key in keys:
#     print(key)

# values()
# values = heros.values()
# print(values)
# print(list(values))

# items()
# items = heros.items()
# print(items)
# print(list(items))
# key,value = list(items)[0]
# print(key)
# print(value)

# 复制 copy
# heros_copy = heros.copy()
# heros.pop('及时雨')
# print(heros)
# print(heros_copy)

